﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.Xml;
using System.ServiceModel.Channels;

namespace NuxeoServicesTest
{
    public partial class NuxeoMainForm : Form
    {
        public NuxeoMainForm()
        {
            InitializeComponent();
        }

        private void btnRepositoryService_Click(object sender, EventArgs e)
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.MessageEncoding = WSMessageEncoding.Mtom;
            binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
            binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

            Uri uriObj = new Uri(@"http://cmis.demo.nuxeo.org:80/nuxeo/webservices/cmis/RepositoryService");
            string value = @"<UsernameToken><Username>Administrator</Username><Password>Administrator</Password></UsernameToken>";
            AddressHeader header = AddressHeader.CreateAddressHeader("Security", @"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", value);
            EndpointAddress endpoint = new EndpointAddress(uriObj, new AddressHeader[]{header});

            CMISServices.RepositoryServicePortClient port = new CMISServices.RepositoryServicePortClient(binding, endpoint);
            //CMISServices.RepositoryServicePortClient port = new CMISServices.RepositoryServicePortClient();
            CMISServices.cmisRepositoryEntryType[] repos = port.getRepositories(null);
        }
    }
}
